package designpattern.demo.creational.prototypepattern;

import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        // 浅拷贝
        //产生一个对象
        Thing thing = new Thing();

        //设置一个值
        thing.setValue("张三");
        //拷贝一个对象
        Thing cloneThing = thing.clone();
        cloneThing.setValue("李四");
        System.out.println(thing.getValue());

        // 深拷贝
        ThingDeepCopy tdc = new ThingDeepCopy();
        ArrayList<String> testList = new ArrayList<>();
        testList.add("22222222222");
        testList.add("3333333333332");
        tdc.setArrayList(testList);

        ThingDeepCopy thingDeepCopy2 = tdc.clone();
        thingDeepCopy2.getArrayList().forEach(e -> System.out.println(e));


    }


}
